<style>
    .twoDiv{
        padding: 10px 0px;
        border-bottom: 1px solid #f6f6f6;
        color: #333;
        height: 60px;
    }
    .three{
        height: 500px;
        padding: 10px 0px;
    }
</style>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">数据概览</div>

                        <div class="layui-card-body">
                            <div class="twoDiv ">
                                <form class="layui-form layui-form-pane" action="#" lay-filter="example">
                                    <div class="layui-col-md10">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">承担单位：</label>
                                            <div class="layui-inline">
                                                <input type="tel" name="forwardingunit" id="forwardingunit" autocomplete="off" class="layui-input">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-col-md2">
                                        <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">搜索</button>
                                    </div>
                                </form>
                            </div>
                            <div class="three" >
                                <table class="layui-hide" id="test" lay-filter="test"></table>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="getCheckData">新增物流承担方</button>
    </div>
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
</script>
<script>
    layui.use(['table', 'form', 'jquery', 'layer', 'tree','util'], function () {
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        table.render({
            elem: '#test'
            , url: '../../getAllLogisticsxcl'
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            , title: '物流承担方'
            ,id:'yi'
            ,height:500
            ,limit:10
            ,limits:[10,20,30,40,50]
            ,page: true //开启分页
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'forwardingunit', title: '承担单位', width: 180,sort: true}
                , {field: 'phone', title: '电话号码'}
                , {field: 'alternatephone', title: '备用电话', edit: 'text', sort: true}
                , {field: 'bankcard', title: '银行卡号'}
                , {field: 'remark', title: '备注地址'}
                , {field: 'name', title: '联系人名称', sort: true}
                , {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150}
            ]]
        });

        //添加物流承担商
        table.on('toolbar(test)', function(obj){
            switch(obj.event){
                case 'getCheckData':
                    layer.open({
                        type: 2,
                        title: '订单派送',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['1300px', '500px'],
                        content: '/src/views/client/iframe/addlogistics.html?id='+0 //iframe的url
                    });
                    break;
            };
        });

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            //修改
            if(obj.event === 'edit'){
                layer.open({
                    type: 2,
                    title: '订单派送',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['1300px', '400px'],
                    content: '/src/views/client/iframe/addlogistics.html?id='+data.logisticsId //iframe的url
                });
            }
        });



        //搜索
        form.on('submit(demo1)', function(data){
            //执行重载
            table.reload('yi', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                //根据条件查询
                ,where: {
                    forwardingunit:$("#forwardingunit").val(),
                    id:"1"
                }
            });
            return false;
        });


    });
</script>


